<template>
    <div>
        <!-- 招标模块的审核历史 -->
        <div class="e-table" v-if="typeName === '招标'">
            <el-table
                ref="history"
                :data="tableData2"
                border
                style="width: 100%"
                @cell-mouse-enter="cellMouseEnter"
                @cell-mouse-leave="cellMouseLeave"
                :cell-class-name="cellClsNm"
                v-sortTable="{ 'tableData': tableData2, '_this': this, 'ref': 'history' }"
                class="table"
            >
                <el-table-column show-overflow-tooltip prop="unitName" label="审核级次" width="150">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="assignUser" label="审核人" width="120">
                </el-table-column>
                <el-table-column
                    show-overflow-tooltip
                    prop="notifyTime"
                    label="通知时间"
                    width="180"
                >
                </el-table-column>
                <el-table-column
                    show-overflow-tooltip
                    prop="completeTime"
                    label="审核时间"
                    width="180"
                >
                </el-table-column>
                <el-table-column
                    show-overflow-tooltip
                    prop="opinion"
                    label="审核意见"
                    min-width="200"
                >
                </el-table-column>
            </el-table>
            <!-- <ComPagination
                v-if="pagination.total"
                :total="pagination.total"
                :pageSize.sync="pagination.pageSize"
                :currentPage.sync="pagination.currentPage"
                :tableData.sync="tableData2"
            /> -->
        </div>
        <!-- 其他模块的审核历史 -->
        <div class="e-table" v-else>
            <el-table
                ref="history"
                :data="tableData"
                border
                style="width: 100%"
                @cell-mouse-enter="cellMouseEnter"
                @cell-mouse-leave="cellMouseLeave"
                :cell-class-name="cellClsNm"
                v-sortTable="{ 'tableData': tableData, '_this': this, 'ref': 'history' }"
                class="table"
            >
                <el-table-column show-overflow-tooltip prop="unitName" label="审核级次" width="150">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="assignUser" label="审核人" width="120">
                </el-table-column>
                <el-table-column
                    show-overflow-tooltip
                    prop="notifyTime"
                    label="通知时间"
                    width="180"
                >
                </el-table-column>
                <el-table-column
                    show-overflow-tooltip
                    prop="completeTime"
                    label="审核时间"
                    width="180"
                >
                </el-table-column>
                <el-table-column
                    show-overflow-tooltip
                    prop="opinion"
                    label="审核意见"
                    min-width="200"
                >
                </el-table-column>
            </el-table>
            <!-- <ComPagination
                v-if="pagination.total"
                :total="pagination.total"
                :pageSize.sync="pagination.pageSize"
                :currentPage.sync="pagination.currentPage"
                :tableData.sync="tableData"
            /> -->
        </div>
    </div>
</template>

<script>
// import auditRequest from '@/api/tender/audit.js'
// import ComPagination from '@/components/pagination/pagination.vue'
import auditRequest from '@/api/tender/audit.js'

// 组件使用方法
// <ExaHistory
//     :billType="auditParams.billType"
//     :tableData="tableData"
//     @getAuditHistory="getAuditHistory"
// />
// tableData 审核历史数据
// @getAuditHistory 刷新审核历史，用于审核、撤回、作废等等刷新tableData，也可以不传，自己维护tableData

export default {
    props: {
        billType: {
            type: [Number, String],
            required: true
        },
        // 组件传进来的审核历史
        tableData: {
            type: Array,
            default: () => {
                return []
            }
        }
    },
    data () {
        return {
            auditParams: {
                billId: this.$route.query.billid || this.$route.query.tenderId,
                billType: parseInt(this.billType),
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: ''
            },
            pagination: {
                total: 0,
                pageSize: 10,
                currentPage: 1
            },
            // 招标的审核历史
            tableData2: [],
            typeName: ''
        }
    },
    computed: {
        // _tableData: function () {
        //     return this.tableData.length !== 0 ? this.tableData : this.tableData2
        // }
    },
    components: {
        // ComPagination
    },
    created () {
        this.getAuditHistory()
    },
    methods: {
        getAuditHistory () {
            // 如果没传getAuditHistory参数，不传只适合用招标
            if (this.$listeners.getAuditHistory === undefined) {
                this.typeName = '招标'
                auditRequest.getAuditHistory(this.auditParams).then(res => {
                    this.tableData2 = res
                    this.pagination.total = res.length
                })
            } else {
                this.$emit('getAuditHistory')
            }
        },
        cellMouseEnter () {},
        cellMouseLeave () {},
        cellClsNm () {
            return ''
        }
    }
}
</script>

<style lang="sass" scoped></style>
